/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.sistema.aplicacao;

import com.sistema.db.Banco;
import com.sistema.db.LerProperties;
import java.sql.ResultSet;
import javax.swing.*;
import org.pushingpixels.substance.api.skin.SubstanceOfficeBlack2007LookAndFeel;

/**
 *
 * @author geraldo
 */
public class ClassPrincipal
{

    public static void main( String args[] )
    {

        //set LookAndFeel
        SwingUtilities.invokeLater( new Runnable()
        {

            public void run()
            {


                //ativa o lookAndFeel para JFrame e JDialog
                JFrame.setDefaultLookAndFeelDecorated( true );
                JDialog.setDefaultLookAndFeelDecorated( true );


                try
                {
                    UIManager.setLookAndFeel( new SubstanceOfficeBlack2007LookAndFeel() );
                } catch ( Exception e )
                {
                    e.printStackTrace();
                }

                String usuario = "";
                String login = "";
                String senha = "";
                int x = 0;


                LerProperties p = new LerProperties();

                
                if ( p.getLoginAutomatico() == true )
                {
                    Banco conn = new Banco();
                    usuario = System.getProperty( "user.name" );
                    ResultSet rs = conn.executarConsulta( "SELECT login, senha FROM usuarios WHERE login = '" + usuario + "' " );

                    try
                    {
                        while ( rs.next() )
                        {
                            login = rs.getString( "login" );
                            senha = rs.getString( "senha" );
                        }

                        new FormLogin( login, senha );

                    } catch ( Exception e )
                    {
                        e.printStackTrace();
                    }

                } else
                {
                    new FormLogin();
                }



            }
        } );


    }
}
